import 'package:flutter/material.dart';

class TapDemo extends StatefulWidget {
  const TapDemo({super.key});

  @override
  State<TapDemo> createState() => _TapDemoState();
}

class _TapDemoState extends State<TapDemo> {
  String _operation = "No Gesture detected!";
  int _tapCount = 0;

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        GestureDetector(
          onTap: () {
            _tapCount++;
            updateText("Tap ($_tapCount)");
          },
          onDoubleTap: () => updateText("Double Tap"),
          onLongPress: () => updateText("Long Press"),
          child: Container(
            margin: const EdgeInsets.all(20),
            padding: const EdgeInsets.all(20),
            decoration: BoxDecoration(
              color: Colors.blue,
              borderRadius: BorderRadius.circular(10),
            ),
            child: Column(
              children: [
                const Icon(Icons.touch_app, size: 50, color: Colors.white),
                const SizedBox(height: 10),
                Text(
                  _operation,
                  style: const TextStyle(color: Colors.white, fontSize: 16),
                ),
              ],
            ),
          ),
        ),
        const Text("Try: Tap, Double Tap, or Long Press"),
      ],
    );
  }

  void updateText(String text) {
    setState(() {
      _operation = text;
    });
  }
}